<template>
  <div>
    <van-field :label="label" v-model="content" :type="type" :placeholder="placeholder" :rule="rule" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      content: ''
    }
  },
  props: ['label', 'type', 'placeholder', 'rule'],
  methods: {
    handlerulg() {
      const rue = new RegExp(this.rule)
      if (rue.test(this.content)) {
        this.$emit('inputChange', this.content)
      }
      // this.$emit('inputChange', this.content) 二次输入不符合验证法则的账号密码时，content不更新
    }
  },
  watch: {
    content() {
      this.handlerulg()
    }
  }
}
</script>

<style lang="less"></style>
